package m202310.d31;

import java.util.Arrays;

/**
 * @author haocongshun
 * @date 2023/10/31 19:59:48
 * <p>
 * 2037. 使每位学生都有座位的最少移动次数
 */
public class Q2037 {
    public int minMovesToSeat(int[] seats, int[] students) {
        Arrays.sort(seats);
        Arrays.sort(students);
        int result = 0;
        for (int i = 0; i < seats.length; i++) {
            result = result + Math.abs(students[i] - seats[i]);
        }
        return result;
    }
}
